#include "EpilFunctionStatementCode.h"
#include "EpilOutputHelper.h"
#include "TCharSupport.h"
#include "EpilPointerHelper.h"


EpilFunctionStatementCode::EpilFunctionStatementCode( const EpilLexLocation & location )
: EpilStatementCodeBase( location )
, m_body( NULL )
, m_functionName( NULL )
{
}


EpilFunctionStatementCode::~EpilFunctionStatementCode()
{
	EpilPointerHelper::SafeDelete( m_functionName );
	EpilPointerHelper::SafeDelete( m_body );
}


tstring EpilFunctionStatementCode::ToEpilCode( int indent ) const
{
	tstringstream ret;
	ret << EpilOutputHelper::GetIndent( indent );
	ret << t("function ");
	ret << m_functionName->ToEpilCode();
	ret << m_body->GetParameterList()->ToEpilCode();
	ret << endl;
	ret << m_body->GetChunk()->ToEpilCode( indent + 1 );
	ret << endl;
	ret << EpilOutputHelper::GetIndent( indent );
	ret << t("end");
	ret << endl;
	return ret.str();
}